<%@ page pageEncoding="UTF-8"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>文件上传</title>
    <link href="${pageContext.request.contextPath}/views/css/iconfont.css" rel="stylesheet" type="text/css"/>
    <link href="${pageContext.request.contextPath}/views/css/fileUpload.css" rel="stylesheet" type="text/css">
</head>
<body>
	<input type="hidden" value="${filePath }" id="filePath">
    <div id="fileUploadContent" class="fileUploadContent">
		
    </div>
    <input type="checkbox" id="ifopen"/><label for="ifopen">公开文件</label>
</body>
</html>
<script src="${pageContext.request.contextPath}/views/js/libs/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/views/js/fileUpload.js"></script>
<script type="text/javascript">
	//var fileType = "${fileType}";
	//var shuzu = fileType.split(',');
	//alert(shuzu);
    $("#fileUploadContent").initUpload({
        "uploadUrl":"${pageContext.request.contextPath}/file/fileupload",//上传文件信息地址
        //"progressUrl":"#",//获取进度信息地址，可选，注意需要返回的data格式如下（{bytesRead: 102516060, contentLength: 102516060, items: 1, percent: 100, startTime: 1489223136317, useTime: 2767}）
        //"showSummerProgress":false,//总进度条，默认限制
        //"size":350,//文件大小限制，单位kb,默认不限制
        "maxFileNumber":3,//文件个数限制，为整数
        //"filelSavePath":"",//文件上传地址，后台设置的根目录
        "beforeUpload":beforeUploadFun,//在上传前执行的函数
        "onUpload":onUploadFun, //在上传后执行的函数
        //autoCommit:true,//文件是否自动上传
        "fileType":['png','jpg','docx','doc','ppt','pptx','xls','xlsx','pdf','txt','gif','rar','zip','sql']//文件类型限制，默认不限制，注意写的是文件后缀
    })
    function beforeUploadFun(opt){
//        opt.filelSavePath =[{"name":"aaa","value":"gfafjasl"}];
		var ifopen = "";
		if($('#ifopen').is(':checked')){
			ifopen = "0";
		}else{
			ifopen = "1";
		}
        opt.filelSavePath ='{"filepath":"'+$('#filePath').val()+'","ifopen":"'+ifopen+'"}';
    }
    var dialog = frameElement.dialog;
    function onUploadFun(opt,data){
        //alert(data);
        if(data.code==-1){
	        alert(data.msg);
	        return;
        }
        parent.window.BindData();
		dialog.close();
        //uploadTools.uploadError(opt);//显示上传错误
    }
</script>